from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship

from app.db import Base


class Port(Base):
    __tablename__ = 'port'
    id = Column(Integer, primary_key=True, index=True)
    host_port = Column(Integer, nullable=False)
    container_port = Column(Integer, nullable=False)

    storage_id = Column(Integer, ForeignKey('storage.id'))


class Storage(Base):
    __tablename__ = 'storage'

    id = Column(Integer, primary_key=True, index=True)
    service_id = Column(String(255), unique=True)
    main_memory = Column(Integer, default=128)
    slave_memory = Column(Integer, default=None)
    type = Column(Integer, default=None)

    ports = relationship("Port")
